package exercise.day07;

import java.util.Random;
import java.util.Scanner;

public class VerificationCode {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输随机位数");
        int a=scan.nextInt();
        String code = vgenerateVeriCode(a);
        System.out.println("验证码："+code);

        System.out.println("请输随机位数");
        int b=scan.nextInt();
        String code1 = vgenerate(b);
        System.out.println("验证码："+code1);
    }

    public static String vgenerate(int len){
        String code="";
        char[] chs={'a','b','c','d','A','B','C','D','0','1','2',
                    '3','4','5','6','7','8','9','我','是','你','爹'};
        Random rand=new Random();
        for(int i=1;i<=len;i++){
            int index=rand.nextInt(chs.length);
            code+=chs[index];
        }

        return code;

    }





    public static String vgenerateVeriCode(int len) {
        String code = "";
        char[] chs = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                'a', 'b', 'c', 'A', 'B', 'C',};
        Random rand = new Random();
        for (int i = 1; i <=len; i++) {
            int idexn = rand.nextInt(chs.length);
            code += chs[idexn];
        }

        return code;

    }
}
